/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __IMPL_MGR_H__
#define __IMPL_MGR_H__

#include "../tools/head.h"

namespace xos_http
{
    class file;

    class mgr : public net::i_module
    {
    public:
        typedef xos::release_impl<mgr> T;

    public:
        mgr();
        ~mgr();

    public:
        static int static_init( xos_container::i_container * pContainer, net::i_module ** ppv );
        static xos_container::i_container* container();
        static mgr * get();

    public:
        // 
        // 1.如果查找到，就返回
        // 2.如果没找到，按ppFile的情况处理：
        // 
        // ppFile的不同情况：
        // 
        // 1.为null，什么都不做，表明只是一个普通查询
        // 2.*ppFile为null，则创建一个file对象，并清加进去
        // 3.*ppFile不为null，则直接添加它
        // 
        file * get_file_or_add_or_create_if_not_find( const char * lpszUri, file ** ppFile, bool bAutoRelease );

    public:
        // 
        // net::i_module
        // 
        int set_heart_check_interval_ms( int n_heart_interval_ms );

        int set_caller_callback( xos_box::i_notify * pNotify );
        int set_net_callback( xos_box::i_notify * pNotify );
        xos_box::i_notify * get_callback();

        int set_user_data( void* pUserData );
        void* get_user_data();

    protected:
        xos_odbc::i_connect_pool * m_pOdbcConnectPool;

        xos_box::i_str_property * m_pModuleProp;
        thread_lock m_module_lock;

        xos_box::i_notify * m_pNotify;
        void* m_pUserData;

    public:
        int put_back_to_pool();
        int init();
        int term();

    };

} // xos_http

#endif // __IMPL_MGR_H__
